//
// Created by yyl on 2021/11/25.
//


#ifndef GLSL3LIB_MYRENDER_H
#define GLSL3LIB_MYRENDER_H

#include <jni.h>
#include <GLES3/gl3.h>
#include "BaseEntity.h"
#include <ImageDef.h>
#include "../shader/BaseShader.h"
#include "../simple/SimpleShader.h"
#include "../simple/TriangleShader.h"
#include "../shader/VideoShader.h"

class MyRender {

public:
    MyRender();

    ~MyRender();

    void UpdateFrame(int format, int width, int height, uint8_t *pBuffer);

    void
    SetTransformMatrix(float translateX, float translateY, float scaleX, float scaleY, int degree,
                       int mirror);

    void OnSurfaceCreated();

    void OnSurfaceChanged(int width, int height);

    void OnSurfaceDrawFrame();
    void OnSurfaceDestroy();

    void SetProgramType(int type);

    void LoadFragShaderScript(int shaderType, char *shaderString, int strLen);


    static MyRender *GetInstance();

    static void DestroyInstance();

private:
    static MyRender *instance;
    size_t viewPortWidth;
    size_t viewPortHeight;
    TransformMatrix transformMatrix;
    NativeImage renderFrame;
    BaseShader *shader;
    BaseShader *shaderBefore;
};


#endif //GLSL3LIB_MYRENDER_H
